package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-02
 * Time: 11:45
 */

class Animal {
    public String name;
    public int age;


    public void eat() {
//        Animal animal = new Animal();
        System.out.println(this.name + "正在吃饭");
//        return animal;
    }

}

class Dog extends Animal {
    public void houseGuard() {
        System.out.println(this.name + "看门");
    }




    @Override
    public void eat() {
        System.out.println(this.name + "正在吃狗粮");
    }
}

class Cat extends Animal {
    public void catchMouse() {
        System.out.println(this.name + "抓老鼠");
    }
}


public class Test {


    public static void main(String[] args) {
        Animal animal1 = new Animal();
        Animal animal2 = new Animal();

        Cat cat1 = new Cat();
        Dog dog1 = new Dog();

        cat1 = (Cat) animal1;//向下转型Animal->Cat
        animal2 = dog1;//向上转型Dog->Animal-->animal2 = (Animal)dog1;

    }

    public static void main2(String[] args) {
        Dog dog1 = new Dog();
        Animal animal = dog1;
    }


    public static void fun1() {

    }

    public static void fun1(int a) {

    }

    public static void fun1(int b, int c) {

    }

    public static void main1(String[] args) {
        //编译时,根据传入的参数能确定你调用的是哪个方法 ->静态绑定
        fun1();
        fun1(1);
        fun1(1, 1);

    }
}
